package com.ruoyi.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.work.mapper.WorkClientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkMediaWbMapper;
import com.ruoyi.work.domain.WorkMediaWb;
import com.ruoyi.work.service.IWorkMediaWbService;
import com.ruoyi.common.core.text.Convert;

/**
 * 微博媒体资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-02
 */
@Service
public class WorkMediaWbServiceImpl implements IWorkMediaWbService 
{
    @Autowired
    private WorkMediaWbMapper workMediaWbMapper;
    @Autowired
    private WorkClientMapper workClientMapper;
    /**
     * 查询微博媒体资料
     * 
     * @param mediaId 微博媒体资料主键
     * @return 微博媒体资料
     */
    @Override
    public WorkMediaWb selectWorkMediaWbByMediaId(Long mediaId)
    {
        return workMediaWbMapper.selectWorkMediaWbByMediaId(mediaId);
    }

    /**
     * 查询微博媒体资料列表
     * 
     * @param workMediaWb 微博媒体资料
     * @return 微博媒体资料
     */
    @Override
    public List<WorkMediaWb> selectWorkMediaWbList(WorkMediaWb workMediaWb)
    {
        return workMediaWbMapper.selectWorkMediaWbList(workMediaWb);
    }

    /**
     * 新增微博媒体资料
     * 
     * @param workMediaWb 微博媒体资料
     * @return 结果
     */
    @Override
    public int insertWorkMediaWb(WorkMediaWb workMediaWb)
    {
        workMediaWb.setCreateTime(DateUtils.getNowDate());
        workMediaWb.setContacts(workClientMapper.selectWorkClientByClientId(workMediaWb.getContactId()).getClientName());

        return workMediaWbMapper.insertWorkMediaWb(workMediaWb);
    }

    /**
     * 修改微博媒体资料
     * 
     * @param workMediaWb 微博媒体资料
     * @return 结果
     */
    @Override
    public int updateWorkMediaWb(WorkMediaWb workMediaWb)
    {
        workMediaWb.setUpdateTime(DateUtils.getNowDate());
        return workMediaWbMapper.updateWorkMediaWb(workMediaWb);
    }

    /**
     * 批量删除微博媒体资料
     * 
     * @param mediaIds 需要删除的微博媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaWbByMediaIds(String mediaIds)
    {
        return workMediaWbMapper.deleteWorkMediaWbByMediaIds(Convert.toStrArray(mediaIds));
    }

    /**
     * 删除微博媒体资料信息
     * 
     * @param mediaId 微博媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaWbByMediaId(Long mediaId)
    {
        return workMediaWbMapper.deleteWorkMediaWbByMediaId(mediaId);
    }
}
